﻿using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class TestPreview : EditorWindow
{
    private Object obj;
    private Object lastObj;
    private Editor previewObj;

    private void OnGUI()
    {
        obj = EditorGUILayout.ObjectField(obj, typeof(Object), false);
        if ( obj != null && obj != lastObj )
        {
            previewObj = Editor.CreateEditor(obj);
            lastObj = obj;
        }
        if (previewObj != null && previewObj.HasPreviewGUI() ) { 
         previewObj.OnPreviewGUI(GUILayoutUtility.GetRect(400, 400), EditorStyles.label);
        }

    }

}
